package ar.edu.uba.fi.jmit.monitorengine.mock;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import ar.edu.uba.fi.jmit.monitorengine.core.ConfigurationManager;
import ar.edu.uba.fi.jmit.monitorengine.core.RangeObserver;
import ar.edu.uba.fi.jmit.monitorengine.exception.MonitorEngineException;

public class ConfigurationManagerMock extends ConfigurationManager {
	
	private static Map<String, String> monitorTypes;
	
	private static Map<String, String> monitorApplications;
	
	private static Map<String, List<RangeObserver>> rangeObservers;

	public static void useMockConfigurationManager() {
		instance = new ConfigurationManagerMock();
		monitorTypes = new HashMap<String, String>();
		monitorApplications = new HashMap<String, String>();
		rangeObservers = new HashMap<String, List<RangeObserver>>();
	}
	
	public static void addMonitorType(String monitorName, String monitorType) {
		monitorTypes.put(monitorName, monitorType);
	}
	
	public static void addMonitorApplication(String monitorName, String monitorApplication) {
		monitorApplications.put(monitorName, monitorApplication);
	}
	
	public ConfigurationManagerMock() {
		monitorEngineSender = new MonitorEngineSenderMock();
	}
	
	@Override
	public String getMonitorType(String monitorName) {
		return monitorTypes.get(monitorName);
	}
	
	
	@Override
	public String getMonitorApplication(String monitorName)
			throws MonitorEngineException {
		return monitorApplications.get(monitorName);
	}
	
	@Override
	public List<RangeObserver> getRangeObservers(String monitorName) throws MonitorEngineException {
		if (rangeObservers.get(monitorName) != null)
			return rangeObservers.get(monitorName);
		else
			return new LinkedList<RangeObserver>();
	}
	
	@Override
	public void addRangeObservers(String monitorName, List<RangeObserver> rangeObserver) {
		rangeObservers.put(monitorName, rangeObserver);
	}
	
}
